package com.roomwrod.livedata.viewmodel;

import android.app.Application;

import com.roomwrod.livedata.repository.WordRepository;
import com.roomwrod.model.Word;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

public class WordViewModel extends AndroidViewModel {
    WordRepository repository;

    public WordViewModel(@NonNull Application application) {
        super(application);
        repository = new WordRepository();
    }

    public LiveData<List<Word>> findKeysData(String key){
        return repository.getfindKeys(key);
    }

    public void insert(Word... words) {
        repository.insert(words);
    }

    public void delete(int id) {
        repository.delete(id);
    }

    public void update(Word... words) {
        repository.update(words);
    }

    public void clear() {
        repository.clear();
    }

    public LiveData<List<Word>> getAllData() {
        return repository.getAll;
    }
}
